/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package beanControl;

import Utils.Helper;
import Utils.JDBCHelper;
import Utils.StringUtility;
import beanInfo.payOriginal;
import java.util.ArrayList;
import javax.swing.JTable;

/**
 *
 * @author lyan
 */
public class payOriginalControl {

    ArrayList<String> listColumn = new ArrayList<String>();
    ArrayList<String> listValue = new ArrayList<String>();
    payOriginal pay = new payOriginal();

    public void listpurposes(JTable table) {
        String sql = "select * from PayOriginal";
        String[] header = {"Term", "PaymentDate", "ProfileID", "PrincipalBalance", "Money", "Status"};
        Helper.loadDataTable(sql, table, header);
    }

    public void insertpayori(payOriginal pay) {
        Object[] values = { pay.getPaymentDate(), pay.getProfileID(), pay.getPrincipalBalance(), pay.getMoney(), pay.getStatus()};

        JDBCHelper.excuteInsertPlaceHolder("PayOriginal", 5, values);
        Helper.successMessage("Insert  successfull", "wanning");
    }
     public void updatePayOri(payOriginal pay) {
        String[] objColumn = {"PaymentDate","ProfileID","PrincipalBalance","Money","Status"};
        String[] objValues = {pay.getPaymentDate(),String.valueOf( pay.getProfileID()), pay.getPrincipalBalance(), pay.getMoney(), pay.getStatus()};

        listColumn = (ArrayList<String>) StringUtility.ArrayToArrayList(objColumn);
        listValue = (ArrayList<String>) StringUtility.ArrayToArrayList(objValues);
       JDBCHelper.executeUpdate("PayOriginal", listColumn, listValue, "Term", String.valueOf(pay.getTerm()));
        Helper.successMessage("Update Sucessful", "wanning");
    }
    

    public void Deletepayori(payOriginal pay) {
        
            JDBCHelper.excuteDelete("PayOriginal", "Term", String.valueOf(pay.getTerm()));
            Helper.successMessage("Delete successfull", "wanning");
      

    }

}
